use std::{env, fs};

mod lexer;

#[cfg(test)]
mod test {
    mod parse_test;
}

fn main() {
    let args: Vec<String> = env::args().collect();

    if args.len() < 2 {
        eprintln!("Usage: {} <filename>", args[0]);
        std::process::exit(1);
    }

    let filename = &args[1];

    let input = fs::read_to_string(filename).expect("Failed to read file");

    match lexer::tokenize(&input) {
        Ok(tokens) => {
            for token in tokens {
                eprintln!("{}", token.format_output())
            }
        }
        Err(e) => {
            eprintln!("{}", e);
        }
    }
}
